<template>
    <div id="app">
      <div id="upload">
        <el-upload
          :headers="token"
          class="upload-demo"
          ref="upload"
          action="http://localhost:3000/uploadimg"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :file-list="fileList"
          :auto-upload="false">
          <el-button slot="trigger" style="margin-top:200px" size="small" type="primary">选择图片</el-button>
          <el-button style="margin-left: 10px;margin-top: 200px;" size="small" type="primary" @click="submitUpload">提交</el-button>
          <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div> -->
        </el-upload>
      </div>
    </div>
  </template>
  
  <script>
    export default {
    data() {
      return {
        fileList: [],
        token:{
          Authorization:window.localStorage.getItem('token')
        }
      };
    },
    methods: {
      submitUpload() {
        this.$refs.upload.submit();
        // console.log(this.fileList)
      },
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      }
    }
  }
  </script>
  
  <style>
  #app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
    
  }
  #upload{
    width:800px;
    height:500px;
    border:2px dotted gray;
  }
  </style>